<?php

namespace app\common\model;

use think\facade\Cache;
use think\Model;

class TalentListConfModel extends Model
{
    protected static function init()
    {
        static::afterUpdate(function ($user) {
            Cache::rm('talent_list');
        });
        static::afterDelete(function ($user) {
            Cache::rm('talent_list');
        });
    }

    public static function lists(): array
    {
        return Cache::remember('talent_list', function () {
            return static::select()->each(function ($query) {
                $query->content = stripslashes($query->content);
            })->toArray();
        });
    }
}